package com.yfcloud.middleware.storage.datanode.listener.impl;

import com.yfcloud.middleware.storage.datanode.listener.PoseidonListener;
import com.yfcloud.middleware.storage.tools.Constant;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.recipes.cache.ChildData;
import org.apache.curator.framework.recipes.cache.TreeCacheEvent;

public class PeseidonZkListener implements PoseidonListener {

    @Override
    public void childEvent(CuratorFramework curatorFramework, TreeCacheEvent treeCacheEvent) throws Exception {
        ChildData data = treeCacheEvent.getData();
        if (data == null)
            return;
        String path = data.getPath();
        switch (treeCacheEvent.getType()){
            case NODE_UPDATED:
                if(Constant.ALIVE_NODE_HASH.equals(path)){
                    byte[] result = curatorFramework.getData().forPath(Constant.ALIVE_NODE_HASH);
                    if(result != null){
                        String routeTable = result.toString();
                    }
                }
            default:
                break;
        }
    }
}
